var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
}),
o.DateEnum = void 0;
var r, s = t("GlobalUserData"),
l = t("BoxGetView"),
c = t("HallConstant"),
d = t("HallScene"),
h = t("BroadCastMessage"),
p = t("Util"),
u = t("Bounce"),
f = t("Particle"),
m = t("Global"),
_ = t("BaseStorage"),
y = t("ConfirmRewardPanel"),
g = cc._decorator,
v = g.ccclass,
C = g.property; (function(t) {
    t[t.firstDay = 0] = "firstDay",
    t[t.secondDay = 1] = "secondDay",
    t[t.diebDay = 2] = "diebDay",
    t[t.fourthDay = 3] = "fourthDay",
    t[t.fifthDay = 4] = "fifthDay",
    t[t.SixthDay = 5] = "SixthDay",
    t[t.seventhDay = 6] = "seventhDay"
})(r = o.DateEnum || (o.DateEnum = {}));
var b = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.date = r.firstDay,
        e.prefab = null,
        e.titleLabel = null,
        e.tagLabel = null,
        e.valueLabel = null,
        e.maskNode = null,
        e.curNode = null,
        e.iconSpr = null,
        e.titles = ["第一天", "第二天", "第三天", "第四天", "第五天", "第六天", "第七天"],
        e.tags = ["金币", "史诗宝箱", "钻石", "金币", "钻石", "体力", "传说宝箱"],
        e.values = [2e3, 1, 50, 5e3, 100, 50, 1],
        e.isCurMissile = !0,
        e.node_box = null,
        e.node_missile = null,
        e.switchImage = function() {
            var t, e, o, i = this;
            this.isCurMissile ? (t = 1, e = 0, o = 255) : (t = 1.5, e = 255, o = 0),
            this.isCurMissile = !this.isCurMissile,
            this.scheduleOnce(function() {
                cc.tween(i.node_box).to(.5, {
                    opacity: e
                }).start(),
                cc.tween(i.node_missile).to(.5, {
                    opacity: o
                }).call(function() {
                    i.switchImage()
                }).start()
            },
            t)
        },
        e
    }
    return n(e, t),
    e.prototype.init = function(t) {
        var e = this;
        this.titleLabel.string = this.titles[Number(this.date)],
        this.iconSpr.spriteFrame = t[Number(this.date)],
        this.tagLabel.string = this.tags[Number(this.date)],
        this.value = this.values[Number(this.date)],
        this.valueLabel.node.addComponent(u.default).init(1, this.value),
        this.node.scale = 0,
        cc.tween(this.node).to(.5, {
            scale: 1
        },
        {
            easing: "elasticOut"
        }).start(),
        this.refresh(),
        this.date == r.seventhDay && (this.node_box = this.node.getChildByName("icon"), this.node_missile = this.node.getChildByName("missile"), this.node_box.opacity = 0, this.switchImage()),
        this.date != r.seventhDay && this.scheduleOnce(function() {
            if (e.iconSpr.node.width > 83) {
                var t = e.iconSpr.node.width / e.iconSpr.node.height;
                e.iconSpr.node.width = 83,
                e.iconSpr.node.height = 83 / t
            }
        },
        .3)
    },
    e.prototype.refresh = function() {
        if (this.maskNode.active = !1, this.curNode.active = !1, this.num = Number(this.date) + 1, this.num < _.BaseStorage.getInt(m.BaseStorageKey.SignDay, 1) && (this.maskNode.active = !0), this.num == _.BaseStorage.getInt(m.BaseStorageKey.SignDay, 1)) if (_.BaseStorage.getInt(m.BaseStorageKey.clock, 0) < 2) {
            this.curNode.active = !0,
            this.node.stopAllActions(),
            this.node.scale = 1;
            var t = cc.repeatForever(cc.sequence(cc.scaleTo(1, 1.1), cc.scaleTo(1, 1)));
            this.node.runAction(t)
        } else this.maskNode.active = !0
    },
    e.prototype.signIn = function(t, e) {
        var o = this;
        void 0 === e && (e = 1),
        this.value *= e,
        h.default.getInstance().SendMessage(c.Broadcast_Func.Audio, c.Audio_ID.btn_click),
        _.BaseStorage.getInt(m.BaseStorageKey.clock, 0) > 1 && (this.curNode.active = !1, this.node.stopAllActions(), this.maskNode.active = !0);
        var i = null;
        switch (this.date) {
            case r.firstDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.gold,
                num: this.value
            }],
            function() {
                s.default.saveGoldData(!0, o.value),
                cc.find("Canvas").getComponent(d.default).onSetOwnGold(!0),
                o.action()
            });
            break;
            case r.secondDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.epicBox,
                num: this.value
            }],
            function() {
                o.unpack(t, l.Box_Type.middle)
            });
            break;
            case r.diebDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.diamond,
                num: this.value
            }],
            function() {
                s.default.saveDiamondData(!0, o.value),
                cc.find("Canvas").getComponent(d.default).onSetOwnDiamond(!0),
                o.action()
            });
            break;
            case r.fourthDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.gold,
                num: this.value
            }],
            function() {
                s.default.saveGoldData(!0, o.value),
                cc.find("Canvas").getComponent(d.default).onSetOwnGold(!0),
                o.action()
            });
            break;
            case r.fifthDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.diamond,
                num: this.value
            }],
            function() {
                s.default.saveDiamondData(!0, o.value),
                cc.find("Canvas").getComponent(d.default).onSetOwnDiamond(!0),
                o.action()
            });
            break;
            case r.SixthDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.vit,
                num: this.value
            }],
            function() {
                s.default.saveVitData(!0, o.value),
                cc.find("Canvas").getComponent(d.default).onSetOwnVit(!0),
                o.action()
            });
            break;
            case r.seventhDay:
                i = cc.instantiate(cc.resources.get("prefab/confirmRewardPanel")),
            cc.find("Canvas").addChild(i, 100),
            i.getComponent(y.default).initView([{
                type: y.rewardType.legendBox,
                num: this.value
            }],
            function() {
                o.unpack(t, l.Box_Type.senior)
            });
        }
    },
    e.prototype.action = function() {
        h.default.getInstance().SendMessage(c.Broadcast_Func.Audio, c.Audio_ID.get_gold);
        for (var t = 0; t < 20; t++) {
            var e = cc.instantiate(this.prefab),
            o = this.getEndPosOfNode(this.date).convertToWorldSpaceAR(cc.Vec2.ZERO),
            i = this.node.convertToNodeSpaceAR(o),
            n = cc.Vec2.ZERO;
            e.setPosition(n),
            e.parent = this.node,
            e.getComponent(f.default).init(p.Util.getRandomInt(0, 360), p.Util.getRandomInt(200, 400), i, this.iconSpr.spriteFrame)
        }
    },
    e.prototype.getEndPosOfNode = function(t) {
        var e;
        switch (t) {
            case r.fifthDay:
            case r.diebDay:
                e = cc.find("Canvas").getChildByName("frame_diamond");
            break;
            case r.firstDay:
            case r.fourthDay:
                e = cc.find("Canvas").getChildByName("frame_gold");
            break;
            case r.SixthDay:
                e = cc.find("Canvas").getChildByName("frame_vit");
        }
        return e
    },
    e.prototype.unpack = function(t, e) {
        var o = cc.instantiate(t);
        cc.find("Canvas").addChild(o, 100),
        o.getComponent(l.default).showOpenBoxView(e, cc.find("Canvas").getComponent(d.default))
    },
    a([C({
        type: cc.Enum(r)
    })], e.prototype, "date", void 0),
    a([C(cc.Prefab)], e.prototype, "prefab", void 0),
    a([C(cc.Label)], e.prototype, "titleLabel", void 0),
    a([C(cc.Label)], e.prototype, "tagLabel", void 0),
    a([C(cc.Label)], e.prototype, "valueLabel", void 0),
    a([C(cc.Node)], e.prototype, "maskNode", void 0),
    a([C(cc.Node)], e.prototype, "curNode", void 0),
    a([C(cc.Sprite)], e.prototype, "iconSpr", void 0),
    a([v], e)
} (cc.Component);
o.default = b